home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / SCRPTSCH.PAK / SRCHRPL.CPP < prev   
C/C++ Source or Header  |  1997-05-06  |  2KB  |  75 lines

  1. //----------------------------------------------------------------------------
  2. // ObjectWindows
  3. // Copyright (c) 1991, 1996 by Borland International, All Rights Reserved
  4. //----------------------------------------------------------------------------
  5. #include <owl/pch.h>
  6. #include <owl/applicat.h>
  7. #include <owl/dialog.h>
  8. #include <stdlib.h>
  9. #pragma hdrstop
  10. #include "search.h"
  11.  
  12. #define IDD_SEARCHEDITBOX  109
  13. #define IDD_REPLACEEDITBOX 110
  14. #define IDD_MASKEDITBOX       111
  15.  
  16. extern "C"{
  17. int WINAPI _export searchReplaceDialog(HWND ParentHWnd, char *search,
  18.                                        char *replace, char *mask);
  19. }
  20.  
  21. int WINAPI _export
  22. searchReplaceDialog(HWND parentHwnd, char *search, char *replace, char *mask)
  23. {
  24.   const int maxLength = 1024;
  25.   int retVal;
  26.  
  27.   // Create/Initialize a structure to set and retrieve data;
  28.   //
  29.   struct {
  30.      char  srchText[maxLength];
  31.      char  rplcText[maxLength];
  32.      char  maskText[maxLength];
  33.   } dlgData = {"", ""};
  34.  
  35.   try {
  36.     if (parentHwnd == 0) {
  37.       parentHwnd = GetActiveWindow();
  38.     }
  39.  
  40.     TWindow *windowPtr = new TWindow(parentHwnd);
  41.  
  42.     TDialog *optDlg = new TDialog(windowPtr, "SEARCHDLG");
  43.     new TEdit(optDlg, IDD_SEARCHEDITBOX, maxLength);
  44.     new TEdit(optDlg, IDD_REPLACEEDITBOX, maxLength);
  45.     new TEdit(optDlg, IDD_MASKEDITBOX, maxLength);
  46.  
  47.     // Set default value
  48.     if (mask != NULL) {
  49.       strcpy(dlgData.maskText, mask);
  50.     }
  51.   
  52.     optDlg->SetTransferBuffer(&dlgData);
  53.     if ((retVal = (optDlg->Execute())) == IDOK) {
  54.       if (search != NULL) {
  55.         strcpy(search, dlgData.srchText);
  56.       }
  57.       if (replace != NULL) {
  58.         strcpy(replace, dlgData.rplcText);
  59.       }
  60.       if (mask != NULL) {
  61.         strcpy(mask, dlgData.maskText);
  62.       }
  63.     }
  64.  
  65.     delete optDlg;
  66.     delete windowPtr;
  67.   }
  68.   catch(...) {
  69.     MessageBox(NULL, "Problem detected", "Error Initializing Dialog", MB_OK);
  70.   }
  71.  
  72.   return retVal;
  73. }
  74.  
  75.